package org.goobs.logic;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public abstract class LogicEngine {	
	
	private HashSet <Formula> registeredFormulas = new HashSet <Formula> ();
	
	// ----------------
	// ABSTRACT METHODS
	// ----------------
	
	public abstract void inform(String statement);
	
	public abstract boolean evaluate(String statement);
	
	public abstract String query(String expression);
	
	
	// ---------------
	// UTILITY METHODS
	// ---------------
	
	/**
	 * Returns the list of valid symbols used by this engine.
	 * This method should be overwritten by any implemented
	 * engine.
	 */
	public static Collection <Symbol> validSymbols(){
		Collection <Symbol> rtn = new HashSet <Symbol> ();
		for(Symbol s : Symbol.values()){
			rtn.add(s);
		}
		return rtn;
	}
	
	protected void registerSignaled(Formula f){
		this.registeredFormulas.add(f);
	}
	
	protected Set <Formula> getSignaledFormulas(){
		return registeredFormulas;
	}
	
	protected void clearSignaled(){
		for(Formula f : registeredFormulas){
			f.clearSignals();
		}
	}
	
}
